package com.lv.service.adapter

import android.widget.EditText
import com.chad.library.adapter.base.BaseQuickAdapter
import com.lv.common.base.DataBindBaseViewHolder
import com.lv.common.bean.FactoryBorderItemBean
import com.lv.common.imp.OnPositionTListener
import com.lv.service.R
import com.lv.service.databinding.ItemFactoryBorderChildDialogBinding

/**
 * 作者： ygx
 * 创建日期：2022/6/24 8:10 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 *      _              _           _     _   ____  _             _ _
 *     / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 *    / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 *   / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 *  /_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 *
 */
class FactoryBorderChildAdapter(private val datas: MutableList<FactoryBorderItemBean>) :
    BaseQuickAdapter<FactoryBorderItemBean, DataBindBaseViewHolder>
        (R.layout.item_factory_border_child_dialog, datas) {

    override fun convert(helper: DataBindBaseViewHolder, item: FactoryBorderItemBean) {
        val mBinding: ItemFactoryBorderChildDialogBinding =
            helper.getBind() as ItemFactoryBorderChildDialogBinding
        mBinding.itemRoot = item
//        //防止列表闪烁
        mBinding.executePendingBindings()
        val layoutPosition = helper.layoutPosition
        mBinding.clParent.setOnClickListener { onViewClickListener?.onClick(layoutPosition, item) }
//
////        tvName.text = item.name
//        val layoutParams = clParent.layoutParams as RecyclerView.LayoutParams
//        if (layoutPosition == datas.size - 1) {
//            layoutParams.bottomMargin = SizeUtils.dp2px(40.0f)
//        } else {
//            layoutParams.bottomMargin = SizeUtils.dp2px(0.0f)
//        }
//        clParent.layoutParams = layoutParams


    }

    override fun convert(
        holder: DataBindBaseViewHolder,
        item: FactoryBorderItemBean,
        payloads: List<Any>
    ) {
        super.convert(holder, item, payloads)
        val mBinding: ItemFactoryBorderChildDialogBinding =
            holder.getBind() as ItemFactoryBorderChildDialogBinding
        mBinding.itemRoot = item
//        //防止列表闪烁
        mBinding.executePendingBindings()
        mBinding.ivTag.setImageResource(if (item.selected_android == true) com.lv.common.R.drawable.icon_pick else 0)
    }

    var onEditorFocusListener: OnPositionTListener<EditText>? = null
    var onViewClickListener: OnPositionTListener<FactoryBorderItemBean>? = null


}